import { createBrowserRouter, Navigate } from 'react-router-dom';
import Login from '@pages/Login';
import Main from '@pages/main'; // 引入路径
import Home from '@pages/Home'; // 首页
import Commodity from '@pages/Commodity'; // 商品管理
import User from '@pages/User'; // 用户管理
import PageOne from '@pages/Other/page_one'; // 其他页面1
import PageTwo from '@pages/Other/page_two'; // 其他页面2
const Routers = [
  {
    path: "/login",
    Component: Login,
  },
  {
    path: "/", // 根路径
    Component: Main, // 主组件，这里应该直接引用组件，而不是字符串路径
    children: [
      // 此处使用navigate跳转到home('/'重定向到home)
      { 
        path: "/", 
        element: <Navigate to="/home" />,
      },
      {
        path: "home",
        Component: Home, // 子组件，同样应该直接引用组件
      }, {
        path: "commodity",
        Component: Commodity,
      }, {
        path: "user",
        Component: User,
      }, {
        path: "other",
        children: [
          {
            path: "page_one",
            Component: PageOne,
          }, {
            path: "page_two",
            Component: PageTwo,
          }
        ]
      }
    ]
  }
]

export default createBrowserRouter(Routers)